home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / GMS / GMSDev / Source / Asm / Chunky / ChunkyBuffered.s < prev    next >
Encoding:
Text File  |  1998-05-06  |  4.9 KB  |  215 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;This demo is like the other pixel list demos but uses a CHUNKY8 screen type.
  3. ;Then screen size has been kept very small as the C2P routine is too slow,
  4. ;but this will be improved in the next version.  The good thing is that
  5. ;because the routine is transparent, using a graphics card would mean that
  6. ;this demo would run at the maximum possible speed.
  7. ;
  8. ;Press LMB to exit.
  9.  
  10.     INCDIR    "INCLUDES:"
  11.     INCLUDE    "dpkernel/dpkernel.i"
  12.  
  13.     SECTION    "Demo",CODE
  14.  
  15. ;===========================================================================;
  16. ;                             INITIALISE DEMO
  17. ;===========================================================================;
  18.  
  19.     STARTDPK
  20.  
  21. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  22.     move.l    DPKBase(pc),a6
  23.     lea    ScreenTags(pc),a0
  24.     sub.l    a1,a1
  25.     CALL    Init
  26.     tst.l    d0
  27.     beq.s    .Exit
  28.  
  29.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  30.     CALL    Get
  31.     move.l    d0,JoyData
  32.     beq.s    .Exit
  33.     move.l    d0,a0    ;Initialise the joydata structure.
  34.     sub.l    a1,a1
  35.     CALL    Init
  36.     tst.l    .Exit
  37.  
  38.     move.l    Screen(pc),a0
  39.     CALL    Display
  40.  
  41.     bsr.s    Main
  42.  
  43. .Exit    move.l    DPKBase(pc),a6
  44.     move.l    JoyData(pc),a0
  45.     CALL    Free
  46.     move.l    Screen(pc),a0
  47.     CALL    Free
  48.     MOVEM.L    (SP)+,A0-A6/D1-D7
  49.     moveq    #ERR_OK,d0
  50.     rts
  51.  
  52. ;===========================================================================;
  53. ;                                MAIN LOOP
  54. ;===========================================================================;
  55.  
  56. Main:
  57. .loop    move.l    DPKBase(pc),a6
  58.     move.l    Screen(pc),a1
  59.     move.l    GS_Bitmap(a1),a0
  60.     CALL    Clear
  61.  
  62.     lea    MList(pc),a2    ;a2 = Pointer to pixel list.
  63.     move.l    a2,a3    ;Drop the pixels here.
  64.     moveq    #31-1,d7
  65. .drop    addq.w    #1,2(a3)    ;a3 = YCoord+1
  66.     subq.l    #1,4(a3)    ;a3 = (Colour)-1
  67.     bge.s    .colok
  68.     clr.l    4(a3)
  69. .colok    addq.w    #8,a3
  70.     dbra    d7,.drop
  71.  
  72.     move.l    DPKBase(pc),a6
  73.     lea    MouseX(pc),a5
  74.     move.l    JoyData(pc),a0
  75.     CALL    Query
  76.  
  77.     move.l    JoyData(pc),a0
  78.     move.l    JD_Buttons(a0),d0
  79.     btst    #JB_LMB,d0
  80.     bne    .done
  81.  
  82.     move.w    JD_XChange(a0),d0
  83.     move.w    JD_YChange(a0),d1
  84.  
  85.     move.l    Screen(pc),a0    ;a0 = Screen.
  86.     add.w    (a5),d0    ;d0 = (MouseX)+ChangeX
  87.     add.w    2(a5),d1    ;d1 = (MouseY)+ChangeY
  88.  
  89. .ChkRX    cmp.w    GS_Width(a0),d0
  90.     blt.s    .ChkLX
  91.     moveq    #$00,d0
  92.     bra.s    .Calculate
  93.  
  94. .ChkLX    tst.w    d0
  95.     bgt.s    .ChkTY
  96.     move.w    GS_Width(a0),d0
  97.     bra.s    .Calculate
  98.  
  99. .ChkTY    tst.w    d1
  100.     bgt.s    .ChkBY
  101.     move.w    GS_Height(a0),d1
  102.     bra.s    .Calculate
  103.  
  104. .ChkBY    cmp.w    GS_Height(a0),d1
  105.     blt.s    .Calculate
  106.     moveq    #$00,d1
  107.  
  108. .Calculate
  109.     move.w    d0,(a5)
  110.     move.w    d1,2(a5)
  111.  
  112.     move.l    (a5),-(sp)
  113.     moveq    #2,d1
  114.     CALL    FastRandom
  115.     subq.w    #1,d0
  116.     add.w    d0,(a5)
  117.  
  118.     moveq    #2,d1
  119.     CALL    FastRandom
  120.     subq.w    #1,d0
  121.     add.w    d0,2(a5)
  122.  
  123.     move.l    a2,a3
  124.     moveq    #31-1,d7
  125. .tloop    move.l    8(a3),(a3)
  126.     move.l    12(a3),4(a3)
  127.     addq.w    #8,a3
  128.     dbra    d7,.tloop
  129.  
  130.     move.l    BLTBase(pc),a6
  131.     move.l    Screen(pc),a0
  132.     move.l    GS_Bitmap(a0),a0
  133.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  134.     CALL    bltDrawPixelList    ;>> = Draw pixels with clipping.
  135.     move.l    (sp)+,(a5)
  136.  
  137.     move.l    SCRBase(pc),a6
  138.     CALL    scrWaitAVBL
  139.  
  140.     move.l    Screen(pc),a0
  141.     CALL    scrSwapBuffers
  142.     bra    .loop
  143.  
  144. .done    rts
  145.  
  146. ;===========================================================================;
  147. ;                                  DATA
  148. ;===========================================================================;
  149.  
  150. JoyData:    dc.l  0
  151.  
  152. ScreenTags:    dc.l  TAGS_SCREEN
  153. Screen:        dc.l  0
  154.         dc.l  GSA_Width,256
  155.         dc.l  GSA_Height,128
  156.         dc.l  GSA_Attrib,SCR_CENTRE|SCR_DBLBUFFER
  157.         dc.l    GSA_BitmapTags,0
  158.         dc.l    BMA_Palette,.palette
  159.         dc.l    BMA_Type,CHUNKY8
  160.         dc.l    TAGEND,0
  161.         dc.l  TAGEND
  162.  
  163. .palette    dc.l  PALETTE_ARRAY,32
  164.         dc.l  $000000,$101010,$171717,$202020,$272727,$303030
  165.         dc.l  $373737,$404040,$474747,$505050,$575757,$606060
  166.         dc.l  $676767,$707070,$777777,$808080,$878787,$909090
  167.         dc.l  $979797,$a0a0a0,$a7a7a7,$b0b0b0,$b7b7b7,$c0c0c0
  168.         dc.l  $c7c7c7,$d0d0d0,$d7d7d7,$e0e0e0,$e0e0e0,$f0f0f0
  169.         dc.l  $f7f7f7,$ffffff
  170.  
  171. PixelList:    dc.w   32,PXL_SIZEOF    ;Amount of entries, EntrySize.
  172.         dc.l   MList    ;Pointer to pixel list array.
  173. MList:        PIXEL  16,12,00    ;First pixel to draw (at back)
  174.         PIXEL  16,12,00    ;X/Y/Colour
  175.         PIXEL  16,12,00    ;..
  176.         PIXEL  16,12,00    ;..
  177.         PIXEL  16,12,00    ;..
  178.         PIXEL  16,12,00    ;..
  179.         PIXEL  16,12,00    ;..
  180.         PIXEL  16,12,00    ;..
  181.         PIXEL  16,12,00    ;..
  182.         PIXEL  16,12,00    ;..
  183.         PIXEL  16,12,00    ;..
  184.         PIXEL  16,12,00    ;..
  185.         PIXEL  16,12,00    ;..
  186.         PIXEL  16,12,00    ;..
  187.         PIXEL  16,12,00    ;..
  188.         PIXEL  16,12,00    ;..
  189.         PIXEL  16,12,00    ;..
  190.         PIXEL  16,12,00    ;..
  191.         PIXEL  16,12,00    ;..
  192.         PIXEL  16,12,00    ;..
  193.         PIXEL  16,12,00    ;..
  194.         PIXEL  16,12,00    ;..
  195.         PIXEL  16,12,00    ;..
  196.         PIXEL  16,12,00    ;..
  197.         PIXEL  16,12,00    ;..
  198.         PIXEL  16,12,00    ;..
  199.         PIXEL  16,12,00    ;..
  200.         PIXEL  16,12,00    ;..
  201.         PIXEL  16,12,00    ;..
  202.         PIXEL  16,12,00    ;..
  203.         PIXEL  16,12,00    ;..
  204. MouseX:        PIXEL  16,12,31    ;Last pixel to draw (in front)
  205.  
  206. ;===========================================================================;
  207.  
  208. ProgName:    dc.b  "Chunky Buffered",0
  209. ProgAuthor:    dc.b  "Paul Manias",0
  210. ProgDate:    dc.b  "February 1998",0
  211. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1998.  Freely distributable.",0
  212. ProgShort:    dc.b  "Chunky double buffering.",0
  213.         even
  214.  
  215.